package com.wy.component.wxUtils;

import java.io.FileNotFoundException;
import java.io.IOException;

import com.wy.component.properties.PropertiesUtil;


/**
 * @author zhusw
 * @description TODO(参数API类)
 * 2016年2月26日 下午10:46:06
 */
public class ParamesAPI {
	// token
	public static String token = "shwally421";  
	// 随机戳
	public static String encodingAESKey = "rFIUjs9ti1yd2knbqcg9QYkPXqhrRRGC2WzUXQa5i9y";  
	 //你的企业号ID
	public static String corpId = null;
	// 管理组的凭证密钥，每个secret代表了对应用、通讯录、接口的不同权限；不同的管理组拥有不同的secret
	public static String secret = null;
	//企业号会话凭证密钥
	public static String secretChat = null;
	// OAuth2 回调地址
	public static String REDIRECT_URI = "";
	
	public static String agentid = null;
	
	@SuppressWarnings("static-access")
	public ParamesAPI() {
		PropertiesUtil p = new PropertiesUtil();
		try {
			this.corpId = p.getAppProperties("corpId");
			this.secret = p.getAppProperties("secret");
			this.secretChat = p.getAppProperties("secretChat");
			this.agentid = p.getAppProperties("agentid");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static String getAccessToken(){
		return WeixinUtil.getAccessToken(new ParamesAPI().getCorpId(), new ParamesAPI().getSecret()).getToken();
	}
	
	
	public static void resultPostData(String url,String postData){
		int result = WeixinUtil.PostMessage(ParamesAPI.getAccessToken(), "POST", url,postData);// 提交数据,获取结果
		// 打印结果
		if(0==result){
			System.out.println("操作成功");
		}
		else {
			System.out.println("操作失败");
		}
	}

	public static String getToken() {
		return token;
	}

	public static void setToken(String token) {
		ParamesAPI.token = token;
	}

	public static String getEncodingAESKey() {
		return encodingAESKey;
	}

	public static void setEncodingAESKey(String encodingAESKey) {
		ParamesAPI.encodingAESKey = encodingAESKey;
	}

	public static String getCorpId() {
		return corpId;
	}

	public static void setCorpId(String corpId) {
		ParamesAPI.corpId = corpId;
	}

	public static String getSecret() {
		return secret;
	}

	public static void setSecret(String secret) {
		ParamesAPI.secret = secret;
	}

	public static String getSecretChat() {
		return secretChat;
	}

	public static void setSecretChat(String secretChat) {
		ParamesAPI.secretChat = secretChat;
	}

	public static String getAgentid() {
		return agentid;
	}

	public static void setAgentid(String agentid) {
		ParamesAPI.agentid = agentid;
	} 
	
	
	
}
